package cn.net.yugu.doraemon.api.common.event;

import java.io.Serializable;
import java.time.Instant;

import lombok.EqualsAndHashCode;
import lombok.ToString;

/**
 * @author xiangzr
 * @version 2021/5/19 17:40:14
 */
@EqualsAndHashCode
@ToString
public abstract class AbstractEvent<T extends Serializable> implements Event {

    private static final long serialVersionUID = -3543448593759356357L;

    protected final Long eventTime = Instant.now().toEpochMilli();
    protected String eventId;
    protected String eventName;
    protected T data;

    public AbstractEvent() {
    }

    @Override
    public String eventId() {
        return eventId;
    }

    @Override
    public Long eventTime() {
        return eventTime;
    }

    public Long getEventTime() {
        return this.eventTime;
    }

    public String getEventId() {
        return this.eventId;
    }

    public String getEventName() {
        return this.eventName;
    }

    public T getData() {
        return this.data;
    }

    public void setEventId(String eventId) {
        this.eventId = eventId;
    }

    public void setEventName(String eventName) {
        this.eventName = eventName;
    }

    public void setData(T data) {
        this.data = data;
    }

}
